package com.hp.springioc04;

import com.hp.springioc01.AMDCPU;
import com.hp.springioc01.CPU;
import com.hp.springioc01.KingstonMemory;
import com.hp.springioc01.Memory;

/**
 * 电脑
 */
public class Computer {

    @MyValue("大苹果")
    private String brand;

    @MyComponent(AMDCPU.class)
    private CPU cpu;

    @MyComponent(KingstonMemory.class)
    private Memory memory;

    public void start(){
        System.out.println(brand+"品牌的电脑启动了");
        cpu.run();
        memory.read();
        memory.write();
    }

    public Computer(String brand, CPU cpu, Memory memory) {
        this.brand = brand;
        this.cpu = cpu;
        this.memory = memory;
    }

    public Computer(CPU cpu, Memory memory) {
        this.cpu = cpu;
        this.memory = memory;
    }

    public Computer() {
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public CPU getCpu() {
        return cpu;
    }

    public void setCpu(CPU cpu) {
        this.cpu = cpu;
    }

    public Memory getMemory() {
        return memory;
    }

    public void setMemory(Memory memory) {
        this.memory = memory;
    }
}
